package jevon.philautus.service.impl;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import jevon.philautus.domain.Pager;
import jevon.philautus.domain.Role;
import jevon.philautus.service.RoleService;
import jevon.philautus.stereotype.Log;
import jevon.philautus.utils.DBHelper;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

@Service
public class RoleServiceImpl implements RoleService {

	@PersistenceContext
	EntityManager em;
	
	@Log
	private Logger logger;
	
	@Override
	public void save(Role role) {
		logger.debug("persist role");
		em.persist(role);
	}

	/**
	 * 获取角色的列表
	 */
	@Override
	public Pager<Role> list(Pager<Role> pager) {
		String sql = "from Role r";
		return DBHelper.pager(sql, pager, em);
	}

}
